package at.fhhagenberg.mcm09.elevator.model;

import java.util.Queue;

import junit.framework.TestCase;

public class RequestModelTest extends TestCase{
	
	RequestModel model;
	Queue<StopRequest> queue;
	
	public RequestModelTest(){
		
		model = new RequestModel();
		queue = model.getStopQueue();
	}

	public void testADD(){
		
		model.addRequest(new StopRequest(0));
		assertEquals(1, queue.size());
		model.addRequest(new StopRequest(0));
		assertEquals(1, queue.size());
		model.addRequest(new CallRequest(0,true));
		assertEquals(2, queue.size());
		model.addRequest(new CallRequest(0,true));
		assertEquals(2, queue.size());
		model.addRequest(new StopRequest(1));
		model.addRequest(new CallRequest(1,true));
		assertEquals(4, queue.size());
		
	}
	
	public void testREMOVE(){
		
		model.addRequest(new StopRequest(0));
		assertEquals(1, queue.size());
		model.addRequest(new CallRequest(0, true));
		assertEquals(2, queue.size());
		model.addRequest(new StopRequest(1));
		assertEquals(3, queue.size());
		model.removeRequest(new StopRequest(0));
		assertEquals(2, queue.size());
		model.removeRequest(new CallRequest(0,true));
		assertEquals(1, queue.size());
		model.removeRequest(new StopRequest(5));
		assertEquals(1, queue.size());
		model.removeRequest(new CallRequest(5, true));
		assertEquals(1, queue.size());
		model.removeRequest(new StopRequest(1));
		assertEquals(0, queue.size());
		model.removeRequest(new StopRequest(1));
		assertEquals(0, queue.size());
	}
}
